<?php defined('RUN_KATANA') or die('Restricted access'); ?>
<?php 
if(!$_POST)
{
	$out = '';
	if($ac->getUsers())
	{
		$levels = $ac->getAccessLevels();
		$groups = $ac->getUserGroups();
		foreach($ac->getUsers() as $item)
		{
			$out .= '<tr class="items">';
			$out .= '<td class="first center">'.$item->getId().'</td>';
			$out .= '<td>';
			$out .= 	'<input type="hidden" name="user_id[]" value="'.$item->getId().'" />';
			$out .= 		'<div style="display:none;">'.$item->getUsername().' '.$item->getEmail().' '.$item->getCompany().'</div>';
			$out .= 	'<input class="select_list" type="checkbox" name="selected[]" value="'.$item->getId().'" /></td>';
			$out .= '<td><input class="small" name="user_username[]" type="text" value="'.$item->getUsername().'" maxlength="100" /></td>';
			$out .= '<td><input class="small-m" name="user_email[]" type="text" value="'.$item->getEmail().'" maxlength="100" /></td>';
			$out .= '<td><input class="small-m" name="user_company[]" type="text" value="'.$item->getCompany().'" maxlength="100" disabled="disabled" /></td>';
			$out .= '<td>';
			$out .= 	'<select name="user_group[]" class="small" onchange="submit();">';
			$out .= 		'<option value="0" '.$txt->getIsSelectedHTML($item->getLevel(), 0) .'>'.ucfirst($txt->getWord('undefined')).'</option>';
						if($groups)
						{
							foreach($groups as $group)
							{ $out .= '<option value="'.$group->getId().'" '.$txt->getIsSelectedHTML($item->getGroup(), $group->getId()) .'>'.$group->getTitle().'</option>'; }
						}
			$out .= 	'</select>';
			$out .= '</td>';
			$out .= '<td>';
			$out .= 	'<select name="user_level[]" class="small" onchange="submit();">';
			$out .= 	'<option value="0" '.$txt->getIsSelectedHTML($item->getLevel(), 0) .'>'.ucfirst($txt->getWord('user_group').' '.$txt->getWord('defined')).'</option>';
					if($levels)
					{
						foreach($levels as $level)
						{ $out .= '<option value="'.$level->getId().'" '.$txt->getIsSelectedHTML($item->getLevel(), $level->getId()) .'>'.$level->getId().' - '.$level->getTitle().'</option>'; }
					}
			$out .= 	'</select>';
			$out .= '</td>';
			if($ac->getSetting('partner-accounts') > 0)
			{
				$out .= '<td>';
				$out .= 	'<select name="PartnerStatus[]" class="small-m" onchange="submit();">';
				$out .= 		'<option value="0" '.$txt->getIsSelectedHTML($item->getPartnerStatus(), 0) .'>'.ucfirst($txt->getWord('no')).'</option>';
				$out .= 		'<option value="1" '.$txt->getIsSelectedHTML(1, $item->getPartnerStatus()) .'>'.ucfirst($txt->getWord('request').' '.$txt->getWord('sent')).'</option>'; 
				$out .= 		'<option value="5" '.$txt->getIsSelectedHTML(5, $item->getPartnerStatus()) .'>'.ucfirst($txt->getWord('standard')).' (5)'.'</option>';
				$out .= 		'<option value="15" '.$txt->getIsSelectedHTML(15, $item->getPartnerStatus()) .'>'.ucfirst($txt->getWord('pro')).' (15)'.'</option>';
				$out .= 		'<option value="10000" '.$txt->getIsSelectedHTML(10000, $item->getPartnerStatus()) .'>'.ucfirst($txt->getWord('premium')).' (*)'.'</option>';
				$out .= 	'</select>';
				$out .= '</td>';
				$out .= '<td>';
					$out .= $item->getPartnerClicks();
					$out .= ' / ';
					$out .= $item->getPartnerViews();
					if(($item->getPartnerClicks() > 0) && ($item->getPartnerViews() > 0))
					{ $out .= ' ('.round(($item->getPartnerClicks()/$item->getPartnerViews()),2).' %)'; }
				$out .= '</td>';
			}
			if(is_object($adc))
			{
				$out .= '<td>';
				$out .= '<a target="_blank" href="?con=6&list=ad&user='.$item->getId().'">'.ucfirst($txt->getWord('view').' '.$txt->getWord('all')).'</a>';
				$out .= '</td>';
				$out .= '<td>';
				$out .= $item->getConversions();
				$out .= '</td>';
			}
			//$out .= '<td class="small-m">'.$item->getRegisterDate().'</td>';
			//$out .= '<td class="small-m">'.$item->getLastvisitDate().'</td>';
			$out .= '<td>';
				$out .= $commander->getActivationFieldsObjectAjax($item);
				$out .= '<input type="hidden" name="user_active[]" value="'.$item->getActive().'" />';
			$out .= '</td>';
			if(($user->getLevel() > 4) && ($user->getLevel() >= $item->getLevel()))
			{
				$out .= '<td class="center">';
				$out .= 	'<a target="_blank" href="/?action=login&username='.$item->getEmail().'&amp;password='.$item->getPassword().'">';
				$out .= 		'<img title="'.ucfirst($txt->getWord('login').' '.$txt->getWord('as')).'.." class="icon command" src="'.SYSICONS_URL.'locked_16.png" />';
				$out .= 	'</a>';
				$out .= '</td>';
			}
			$out .= '<td class="center">';
			//href="?con='.$_REQUEST['con'].'&amp;user='.$item->getId().'"
			$out .= 	'<a target="_blank"  onclick="editDialog('.$item->getId().');" ><img title="'.ucfirst($txt->getWord('edit')).'" class="icon command" src="'.SYSICONS_URL.'configure_16.gif" /></a>';
			$out .= '</td>';
			/*
			$out .= '<td class="last center">';
			if($item->getId() > 1)
			{
				$out .= '<img title="'.ucfirst($txt->getWord('delete').' '.$txt->getWord('user')).'" class="icon command provider_delete" src="'.SYSICONS_URL.'delete_16.gif" onclick="deleteDialog('.$item->getId().');" />';
			}
			$out .= '</td>';
			*/
			$out .= '</tr>';
		}
	}
	else
	{
		$out .= '<tr class="items">';
		$out .= '<td class="first center">0</td>';
		$out .= '<td class="center">';
		$out .= 	'<input class="select_list" type="checkbox" name="selected[]" value="0" /></td>';
		$out .= '<td>'.ucfirst($txt->getWord('no_items')).'</td>';
		$out .= '<td><input type="hidden" name="user_active[]" value="0" /></td>';
		$out .= '<td>&nbsp;</td>';
		$out .= '<td class="last center">&nbsp;</td>';
		$out .= '</tr>';
	}
	echo $out;
}
?>